# -*- coding: utf-8 -*-v
#coding=utf-8

#scenicdb 代理module
__author__ = 'Leon'

import urllib, urllib2, json




#post 数据
def exesql(param, query, args, url):
    #jstr = json.dumps({u'param': param, u'query': query, u'args': args}, ensure_ascii=False, encoding='utf-8')
    jstr = json.dumps({u'param': param, u'query': query, u'args': args})
    headers = {"Content-Type": "application/json",
               'User-Agent': 'scenicdb client',
               "Accept": "*/*",
               "Accept-Encoding": "gzip,deflate,sdch"}
    req = urllib2.Request(url, jstr, headers=headers)

    #for k, v in data.iteritems():
    #data[k] = unicode(v).encode('utf-8')
    #args = urllib.urlencode(data)
    #enable cookie
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
    #jstr = unicode(jstr).encode('utf-8')
    response = opener.open(req)
    return response.read()
